package com.nongda.mapper;

import com.github.pagehelper.Page;
import com.nongda.dto.ChuKuDto;
import com.nongda.dto.LiuShuiChaCunDto;
import com.nongda.dto.LiuShuiDto;
import com.nongda.pojo.LiuShui;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface TaiZhangMapper {


    int chuku(ChuKuDto chuKuDto);
@Update("update cangku set number=number-#{number} where id=#{id}")
    void chuku_cangku(ChuKuDto chuKuDto);

@Select("select num from cangku_mendian where city_id=#{cityId} and shangpin_id=#{id}")
    int chaxun(ChuKuDto chuKuDto);
@Insert("insert into  liushui (id,shangpin_id, update_time, status, num ) VALUE " +
        "(#{id},#{shangPinId},#{updateTime},#{status},#{num})")
    void dingdan(LiuShuiDto liuShuiDto);

@Update("update cangku_mendian set num = num-#{number}" +
        " where shangpin_id=#{id} and city_id=#{cityId}")
    void ruku_mendian(ChuKuDto chuKuDto);

@Update("update cangku set number =number+#{number} where id=#{id}")
    void ruku(ChuKuDto chuKuDto);
@Select("select id from liushui where id = (select max(id) from liushui)")
    int chukuId(ChuKuDto chuKuDto);
@Select("select number from cangku where name = #{name}")
    int selectNum(LiuShuiChaCunDto liuShuiDto);
@Select("select e.price from shangpin e join cangku c on c.id=e.id where e.name = #{name}")
String sekectPrice(LiuShuiChaCunDto liuShuiDto);


    Page<LiuShui> pageLiuShui(int id);
@Select("select id from shangpin where name=#{name}")
    int selectId(LiuShuiChaCunDto liuShuiDto);
}
